package dnl.toolbox.dto;

/**
 * Defines a base class for all DTO converters.
 * 
 * @author daniel
 */
public abstract class DtoConverter {

	/**
	 * This converter supports only conversion from the type returned by
	 * <code>getClassA()</code> to the type returned to/from
	 * <code>getClassB()</code>.
	 * 
	 * @return one of the two types that this converter can convert from/to.
	 */
	public abstract Class<?> getClassA();

	/**
	 * This converter supports only conversion from the type returned by
	 * <code>getClassA()</code> to the type returned to/from
	 * <code>getClassB()</code>.
	 * 
	 * @return one of the two types that this converter can convert from/to.
	 */
	public abstract Class<?> getClassB();

	/**
	 * Converts a given object.
	 * 
	 * @param obj
	 *            an <code>Object</code> to convert. The object must be either
	 *            of the type returned by <code>getClassA()</code> or the type
	 *            returned by <code>getClassB()</code>.
	 * @param context
	 *            a <code>ConversionContext</code> that is necessary in order
	 *            to keep consistent references accross conversions.
	 * @return return a converted object. 
	 */
	public abstract Object convert(Object obj, ConversionContext context);
}
